var GownFullBrowserDetect = Base.extend({
	constructor: null,
	BROWSER_UNKNOWN: 0,
	BROWSER_IE: 1,
	BROWSER_FIREFOX: 2,
	BROWSER_OPERA: 3,
	BROWSER_KONQUEROR: 4,
	BROWSER_SAFARI: 5,
	BROWSER_MINIMO: 6,
	current_browser: null,
	use_attachEvent: null,
	use_addEventListener: null,
	use_key_addEventListener: null,
	use_mouse_addEventListener: null,
	need_windowreference: null,
	use_css_position_fixed: null,
	use_css_position_absolute: null,
	running_mobile: null,

	init: function()
	{
		this.init_useragent();
		if(this.current_browser == this.BROWSER_UNKNOWN) this.init_objtest();

		Debug.present && (this.current_browser == this.BROWSER_IE) && Debug.trace(0,"GownFullBrowserDetect: Running Internet Explorer.");
		Debug.present && (this.current_browser == this.BROWSER_FIREFOX) && Debug.trace(0,"GownFullBrowserDetect: Running Mozilla Firefox.");
		Debug.present && (this.current_browser == this.BROWSER_OPERA) && Debug.trace(0,"GownFullBrowserDetect: Running Opera.");
		Debug.present && (this.current_browser == this.BROWSER_KONQUEROR) && Debug.trace(0,"GownFullBrowserDetect: Running Konqueror.");
		Debug.present && (this.current_browser == this.BROWSER_SAFARI) && Debug.trace(0,"GownFullBrowserDetect: Running Safari.");
		Debug.present && (this.current_browser == this.BROWSER_MINIMO) && Debug.trace(0,"GownFullBrowserDetect: Running Minimo.");
		Debug.present && (this.current_browser == this.BROWSER_UNKNOWN) && Debug.trace(0,"GownFullBrowserDetect: Running unknown browser.");
		Debug.present && (this.running_mobile) && Debug.trace(0,"GownFullBrowserDetect: Running Mobile device.");
		Debug.present && this.use_attachEvent && Debug.trace(0,"GownFullBrowserDetect: GownFull can use attachEvent.");
		Debug.present && this.use_addEventListener && Debug.trace(0,"GownFullBrowserDetect: GownFull can use addEventListener.");
		Debug.present && this.use_key_addEventListener && Debug.trace(0,"GownFullBrowserDetect: GownFull should use addEventListener on key events.");
		Debug.present && this.use_mouse_addEventListener && Debug.trace(0,"GownFullBrowserDetect: GownFull should use addEventListener on mouse events.");
		Debug.present && this.use_css_position_fixed && Debug.trace(0,"GownFullBrowserDetect: GownFull can use position: fixed in CSS.");
		Debug.present && this.use_css_position_absolute && Debug.trace(0,"GownFullBrowserDetect: GownFull can use position: absolute in CSS.");
	},
	init_useragent: function()
	{
		Debug.trace(0,"GownFullBrowserDetect: Detecting using user-agent...");

		var useragent = navigator.userAgent;

		Debug.trace(0,"GownFullBrowserDetect: %s",useragent);

		useragent = useragent.toLowerCase();

		var isIE = (useragent.indexOf('msie') < 0) ? false : true;
		var isFirefox = (useragent.indexOf('firefox') < 0) ? false : true;
		var isOpera = (useragent.indexOf('opera') < 0) ? false : true;
		var isKonqueror = (useragent.indexOf('konqueror') < 0) ? false : true;
		var isSafari = (useragent.indexOf('safari') < 0) ? false : true;
		var isMinimo = (useragent.indexOf('minimo') < 0) ? false : true;
		var isPPC = (useragent.indexOf('ppc') < 0) ? false : true;
		var isWinCE = (useragent.indexOf('windows ce') < 0) ? false : true;

		if(isOpera && isIE) isIE = false;

		if(isIE) this.current_browser = this.BROWSER_IE;
		else if(isFirefox) this.current_browser = this.BROWSER_FIREFOX;
		else if(isOpera) this.current_browser = this.BROWSER_OPERA;
		else if(isKonqueror) this.current_browser = this.BROWSER_KONQUEROR;
		else if(isSafari) this.current_browser = this.BROWSER_SAFARI;
		else if(isMinimo) this.current_browser = this.BROWSER_MINIMO;
		else this.current_browser = this.BROWSER_UNKNOWN;

		this.use_attachEvent = (isIE) ? true : false;
		this.use_addEventListener = (isFirefox || isMinimo || isOpera || isKonqueror || isSafari) ? true : false;
		this.use_key_addEventListener = (isFirefox || isMinimo || isKonqueror || isSafari) ? true : false;
		this.use_mouse_addEventListener = (isFirefox || isMinimo || isOpera || isKonqueror || isSafari) ? true : false;
		this.need_windowreference = (isKonqueror || isSafari) ? true : false;
		this.running_mobile = (isPPC || isWinCE) ? true : false;
		if(this.running_mobile) {
			this.use_css_position_fixed = false;
			this.use_css_position_absolute = false;
		}
		else {
			this.use_css_position_fixed = (isFirefox || isMinimo || isOpera || isKonqueror || isSafari) ? true : false;
			this.use_css_position_absolute = true;
		}
	},
	init_objtest: function()
	{
		Debug.trace(0,"GownFullBrowserDetect: Detecting using object existence...");
	
		this.use_attachEvent = (document.attachEvent) ? true : false;
		this.use_addEventListener = (document.addEventListener) ? true : false;
		this.use_key_addEventListener = (document.addEventListener) ? true : false;
		this.use_mouse_addEventListener = (document.addEventListener) ? true : false;
		this.use_css_position_fixed = true;

		lib.RunScript('var x = 123;');
		try { this.need_windowreference = (x == null || x != 123) ? true : false; }
		catch(e) { this.need_windowreference = true; }

		if(this.use_attachEvent) this.current_browser = this.BROWSER_IE;
		else this.current_browser = this.BROWSER_UNKNOWN;


		Debug.present && (this.current_browser == this.BROWSER_IE) && Debug.trace(0,"GownFullBrowserDetect: Running Internet Explorer.");
		Debug.present && (this.current_browser == this.BROWSER_UNKNOWN) && Debug.trace(0,"GownFullBrowserDetect: Running unknown browser.");
	}
});


